package com.ssy.lingxi.order.repository;

import com.ssy.lingxi.order.entity.MemberPaymentParameterDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 会员支付参数设置Jpa仓库
 * @author 万宁
 * @version 2.0.0
 * @date 2021-08-11
 */
@Repository
public interface MemberPaymentParameterRepository extends JpaRepository<MemberPaymentParameterDO, Long>, JpaSpecificationExecutor<MemberPaymentParameterDO>, QuerydslPredicateExecutor<MemberPaymentParameterDO> {
    List<MemberPaymentParameterDO> findByMemberIdAndRoleId(Long memberId, Long roleId);

    List<MemberPaymentParameterDO> findByPayTypeAndPayChannel(Integer payType, Integer payChannel);

    MemberPaymentParameterDO findFirstByMemberIdAndRoleIdAndPayTypeAndPayChannel(Long memberId, Long roleId, Integer payType, Integer payChannel);

    @Transactional
    void deleteByMemberIdAndRoleId(Long memberId, Long roleId);
}
